 						var searchParams;
						$(function(){
							//添加按钮事件
							$('#addmenu').on('click', function() {
								var node = businessTable.datagrid('getSelected');
								if (node) {
									openaddmenu( node.businessId);
								} else {
									layer.msg('请选择一个商家！', {
										time : 1000
									})
								}
							});
							//修改按钮事件
							$('#editmenu').on('click', function() {
								var node = shopmenuTable.datagrid('getSelected');
								if (node) {
									openeditmenu(node.foodMenuId);
								} else {
									layer.msg('请选择一条数据！', {
										time : 1000
									})
								}
							});
							//启用禁用按钮事件
							$('#delmenu').on('click', function() {
								delmenu();
							});
							//删除按钮事件
							$('#deletemenu').on('click', function() {
								deletemenu();
							});
							//查询按钮事件
							$('#searchmenu').on('click', function() {
								opensearchmenu();
							});
							//特价菜按钮事件
							$('#foodType').on('click', function() {
								var node = businessTable.datagrid('getSelected');
								if (node) {
									openFoodType( node.businessId);
								} else {
									layer.msg('请选择一个商家！', {
										time : 1000
									})
								}
							});
							//导入EXCEl按钮事件
							$('#fromMenuExcel').on('click', function(){
								var node = businessTable.datagrid('getSelected');
								if (node) {
									fromMenuExcel(node.businessId);
								} else {
									layer.msg('请选择一个商家！', {
										time : 1000
									})
								}
								
							});
							//导出EXCEl按钮事件
							$('#outMeauExcel').on('click', function() {
								outMeauExcel();
							});
						});
						//Table表格数据源
						var shopmenuTable = $('#shopmenu_table').datagrid(BasicData.createDatagrid({  
							url : '',
							checkOnSelect:true,
							singleSelect:true,
							selectOnCheck:true,
							frozenColumns:[[
								{field:'ck',checkbox:false,hidden:true},
								{title:'foodMenuId',field:'foodMenuId',hidden:true}
							]],
							columns:[[
								{field:'name',title:'名称',width:'15%',sortable:true,align:'center'},
								{field:'sorts',title:'排序',width:'14%',sortable:true,align:'center'},
								{field:'addTime',title:'创建时间',width:'30%',sortable:true,align:'center' ,formatter:function(value,row,index){
				                	return timestampToTime(value);
				    			   } }
							]],
							onDblClickRow:function(rowIndex, rowData){
								
							},
							 onClickRow : function(index, row){
								 $("#food_table").datagrid({url:rootpath+'/hhFood/list.do?foodMenuId='+row.foodMenuId})
							}
						}));  
						//打开上传excel页面
						function fromMenuExcel(businessId){
							 layer.open({
									title : '导入',
									type : 2,
									btn : ['保存','关闭'],
									yes : function(index,layero) {
										var iframeWin = window[layero.find('iframe')[0]['name']];
										iframeWin.parentIframeName = window.name;
										iframeWin.$("#dataForm").submit();
										layer.close(index);
										layer.msg('提交成功！', {
											icon : 1,
											time : 1000
										}, function() {
											//刷新列表
											shopmenuTable.datagrid('reload');
										})
									},
									btn2 : function(index, layero) {
									},
									area : [ '20%', '30%' ],
									content : rootpath + '/hhFoodMenu/toUploadExcel.do?businessId='+businessId
								});
						}
						//新增打开窗体
						function openaddmenu(businessId){
							layer.open({
								title : '新增',
								type : 2,
								btn : ['保存','关闭'],
								yes : function(index,layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									iframeWin.parentIframeName = window.name;
									iframeWin.$("#dataForm").submit();
								},
								btn2 : function(index, layero) {
								},
								area : [ '80%', '80%' ],
								content : rootpath + '/hhFoodMenu/toEdit.do?businessId='+businessId
							});
						}
						//导出模板
						function outMeauExcel(){
							window.location.href=rootpath+'/hhFoodMenu/excel.do';
						}
						//打开查询窗体
						function opensearchmenu(){
							layer.open({
								title : '查询条件',
								type : 2,
								btn : ['查询','重置'],
								yes : function(index,layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									searchParams = iframeWin.$("#searchForm").serialize();
									var newparam = iframeWin.$("#searchForm").serializeJSON();
									iframeWin.parentIframeName = window.name;
									$.extend(newparam,shopmenuTable.queryParams);
									$('#shopmenu_table').datagrid('load',newparam);
									layer.close(index);
								},
								btn2 : function(index, layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									iframeWin.parentIframeName = window.name;
									iframeWin.$("#searchForm").form("clear");
									return false;
								},
								area : [ '80%', '80%' ],
								content : rootpath + '/hhFoodMenu/toSearch.do?'+searchParams
							});
						}
						//打开特价菜设置
						function openFoodType(businessId){
							layer.open({
								title : '查询条件',
								type : 2,
								btn : ['保存','取消'],
								yes : function(index,layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									iframeWin.parentIframeName = window.name;
									iframeWin.$("#dataForm").submit();
								},
								btn2 : function(index, layero) {
									layer.close(index);
								},
								area : [ '80%', '80%' ],
								content : rootpath + '/hhBusiness/toSpecial.do?businessId='+businessId
							});
						}
					
						//编辑打开窗体
						function openeditmenu(foodMenuId){
							layer.open({
								title : '修改',
								type : 2,
								btn : ['保存','关闭'],
								yes : function(index,layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									iframeWin.parentIframeName = window.name;
									iframeWin.$("#dataForm").submit();
								},
								btn2 : function(index, layero) {
								},
								area : [ '80%', '80%' ],
								content : rootpath + '/hhFoodMenu/toEdit.do?foodMenuId='+foodMenuId
							});
						}
						//禁用
						function delmenu(){
							var node = shopmenuTable.datagrid('getSelected');
							if (node) {
								layer.confirm('您确定要删除吗？', {
									btn : [ '确定', '取消' ]
								// 按钮
								}, function() {
									$.ajax({
										cache : true,
										type : "POST",
										url : rootpath + '/hhFoodMenu/delete.do',
										data : {
											foodMenuId : node.foodMenuId
										},
										success : function(data) {
											layer.msg('成功！', {
												icon : 1,
												time : 1000
											}, function() {
												//刷新列表
												shopmenuTable.datagrid('reload');
											})
										}
									});
							}, function() {
							});
							}else {
								layer.msg('请选择一条数据！', {
									time : 1000
								})
							}
						}
						//删除
						function deletemenu(){
							var node = shopmenuTable.datagrid('getSelected');
							if (node) {
								$.ajax({
									cache : true,
									type : "POST",
									url : rootpath + '/hhFoodMenu/deleteMenu.do',
									data : {
										foodMenuId : node.foodMenuId
									},
									success : function(data) {
										 var msg="成功！";
										 var icon=1;
										if(!data.success){
											msg="菜单下有菜品,不允许删除";
											icon=0;
										}
										layer.msg(msg, {
											icon : icon,
											time : 1000
										}, function() {
											//刷新列表
											shopmenuTable.datagrid('reload');
										})
									}
								});
							}else {
								layer.msg('请选择一条数据！', {
									time : 1000
								})
							}
						}
						//食品相关操作开始----------
						var searchParams;
						$(function(){
							//添加按钮事件
							$('#addfood').on('click', function() {
								var node = shopmenuTable.datagrid('getSelected');
								if (node) {
									openaddfood(node.foodMenuId);
								} else {
									layer.msg('请选择一条菜单！', {
										time : 1000
									})
								}
							});
							//修改按钮事件
							$('#editfood').on('click', function() {
								var node = foodTable.datagrid('getSelected');
								if (node) {
									openeditfood(node.foodId);
								} else {
									layer.msg('请选择一条数据！', {
										time : 1000
									})
								}
							});
							//启用禁用按钮事件
							$('#delfood').on('click', function() {
								delfood();
							});
							//删除按钮事件
							$('#deletefood').on('click', function() {
								deletefood();
							});
							//查询按钮事件
							$('#searchfood').on('click', function() {
								opensearchfood();
							});
							//导入EXCEl按钮事件
							$('#fromFoodExcel').on('click', function(){
								var node = businessTable.datagrid('getSelected');
								if (node) {
									fromFoodExcel(node.businessId);
								} else {
									layer.msg('请选择一个商家！', {
										time : 1000
									})
								}
							});
							//导出EXCEl按钮事件
							$('#outFoodExcel').on('click', function() {
								outFoodExcel();
							});
							//菜品规格
							$('#foodTags').on('click', function(){
								var node = foodTable.datagrid('getSelected');
								if (node&& node.isMulttag == 1) {
									foodTags(node.foodId);
								} else {
									layer.msg('请选择一条存在多个规格的菜品！', {
										time : 1000
									})
								}
							});
						});
						//Table表格数据源
						var foodTable = $('#food_table').datagrid(BasicData.createDatagrid({  
							url :'',
							checkOnSelect:true,
							singleSelect:true,
							selectOnCheck:true,
							frozenColumns:[[
								{field:'ck',checkbox:false,hidden:true},
								{title:'foodId',field:'foodId',hidden:true}
							]],
							columns:[[
								{field:'name',title:'名称',width:'14%',sortable:true,align:'center'},
								{field:'price',title:'价格',width:'12%',sortable:true,align:'center'},
								{field:'sorts',title:'排序',width:'12%',sortable:true,align:'center'},
								{field:'subTitle',title:'简短描述',width:'12%',sortable:true,align:'center'},
								{field:'isMulttag',title:'是否存在多规格',sortable:true,align:'center',formatter:function(value,row,index){
									if(value==0){
										return "否";
									}else{
										return "是";
									}
				    			   }},
								{field:'addTime',title:'创建时间',width:'15%',sortable:true,align:'center',formatter:function(value,row,index){
				                	return timestampToTime(value);
				    			   }},
				    			   {field:'img',title:'菜品图片',width:'15%',sortable:true,align:'center',formatter:function(value,row,index){
				    				   return '<img height="36" width="36" style="cursor: pointer;border: 1px solid #AAA;padding: 2px;background-color: #FFF;margin-right: 2px;" onclick="showPic(this);" src="' +imgPath+ value + '" />';
					    			 }}
							]],
							onDblClickRow:function(rowIndex, rowData){
								
							},
							 onClickRow : function(index, row){
					
							 }
						}));
						//打开上传excel页面
						function fromFoodExcel(businessId){
							 layer.open({
									title : '导入',
									type : 2,
									btn : ['保存','关闭'],
									yes : function(index,layero) {
										var iframeWin = window[layero.find('iframe')[0]['name']];
										iframeWin.parentIframeName = window.name;
										iframeWin.$("#foodForm").submit();
										layer.close(index);
										layer.msg('提交成功！', {
											icon : 1,
											time : 1000
										}, function() {
											//刷新列表
											foodTable.datagrid('reload');
											shopmenuTable.datagrid('reload');
										})
									},
									btn2 : function(index, layero) {
									},
									area : [ '20%', '30%' ],
									content : rootpath + '/hhFood/toUploadExcel.do?businessId='+businessId
								});
						}
						
						//导出模板
						function outFoodExcel(){
							window.location.href=rootpath+'/hhFood/excel.do';
						}
						//打开查询窗体
						function opensearchfood(){
							layer.open({
								title : '查询条件',
								type : 2,
								btn : ['查询','重置'],
								yes : function(index,layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									searchParams = iframeWin.$("#searchForm").serialize();
									var newparam = iframeWin.$("#searchForm").serializeJSON();
									iframeWin.parentIframeName = window.name;
									$.extend(newparam,foodTable.queryParams);
									$('#food_table').datagrid('load',newparam);
									layer.close(index);
								},
								btn2 : function(index, layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									iframeWin.parentIframeName = window.name;
									iframeWin.$("#searchForm").form("clear");
									return false;
								},
								area : [ '80%', '80%' ],
								content : rootpath + '/hhFood/toSearch.do?'+searchParams
							});
						}
						//新增打开窗体
						function openaddfood(foodMenuId){
							layer.open({
								title : '新增',
								type : 2,
								btn : ['保存','关闭'],
								yes : function(index,layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									iframeWin.parentIframeName = window.name;
									iframeWin.$("#dataForm").submit();
								},
								btn2 : function(index, layero) {
								},
								area : [ '80%', '80%' ],
								content : rootpath + '/hhFood/toEdit.do?foodMenuId='+foodMenuId
							});
						}
						//编辑打开窗体
						function openeditfood(foodId){
							layer.open({
								title : '信息',
								type : 2,
								btn : ['保存','关闭'],
								yes : function(index,layero) {
									var iframeWin = window[layero.find('iframe')[0]['name']];
									iframeWin.parentIframeName = window.name;
									iframeWin.$("#dataForm").submit();
								},
								btn2 : function(index, layero) {
								},
								area : [ '80%', '80%' ],
								content : rootpath + '/hhFood/toEdit.do?foodId=' + foodId   
							});
						}
						//菜品规格
						function foodTags(foodId){
							layer.open({
								title : '菜品规格',
								type : 2,
								btn : ['关闭'],
								btn2 : function(index, layero) {
								},
								area : [ '70%', '80%' ],
								content : rootpath + '/hhFoodTag/toList.do?foodId=' + foodId
							});
						}
						//禁用
						function delfood(){
							var node = foodTable.datagrid('getSelected');
							if (node) {
								layer.confirm('您确定要删除吗？', {
									btn : [ '确定', '取消' ]
								// 按钮
								}, function() {
									$.ajax({
										cache : true,
										type : "POST",
										url : rootpath + '/hhFood/delete.do',
										data : {
											foodId : node.foodId
										},
										success : function(data) {
											layer.msg('成功！', {
												icon : 1,
												time : 1000
											}, function() {
												//刷新列表
												foodTable.datagrid('reload');
											})
										}
									});
								}, function() {
								});
							}else {
								layer.msg('请选择一条数据！', {
									time : 1000
								})
							}
						}
						//删除
						function deletefood(){
							var node = foodTable.datagrid('getSelected');
							if (node) {
								layer.confirm('您确定要删除吗？', {
									btn : [ '确定', '取消' ]
								// 按钮
								}, function() {
									$.ajax({
										cache : true,
										type : "POST",
										url : rootpath + '/hhFood/deletefood.do',
										data : {
											FOOD_ID : node.FOOD_ID
										},
										success : function(data) {
											var msg="成功！";
											var icon=1;
											if(!data.success){
												icon=0;
												msg="菜品不允许删除";
											}
											layer.msg(msg, {
												icon : icon,
												time : 1000
											}, function() {
												if(data.success){
													//刷新列表
													foodTable.datagrid('reload');
												}
											})
										}
									});
								}, function() {
								});
								
								
							}else {
								layer.msg('请选择一条数据！', {
									time : 1000
								})
							}
						}